package pers.jason.wppm.security.core.social;

import org.springframework.social.security.SocialAuthenticationFilter;
import org.springframework.social.security.SpringSocialConfigurer;

/**
 * @ClassName: DefaultSpringSocialConfig
 * @Author: JZH
 * @Date: 2018/12/1 21:48
 * spring social只拦截 /auth 的请求，使用 /signin 作为登陆失败界面，使用 /signup作为左侧界面，因此需要自定义
 */
public class DefaultSpringSocialConfig extends SpringSocialConfigurer {

    private String filterProcessesUrl;

    public DefaultSpringSocialConfig(String filterProcessesUrl) {
        this.filterProcessesUrl = filterProcessesUrl;
    }

    /**
     * 该方法的参数T即为filter，将会加到过滤器链上
     * @param object
     * @param <T>
     * @return
     */
    @Override
    protected <T> T postProcess(T object) {
        SocialAuthenticationFilter socialAuthenticationFilter = (SocialAuthenticationFilter) super.postProcess(object);
        socialAuthenticationFilter.setFilterProcessesUrl(filterProcessesUrl);
        return (T) socialAuthenticationFilter;
    }
}
